package com.klasster.recruitmentPlatform.common.response;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result {

    /**
     * 返回码
     */
    private Integer code;

    /**
     * 返回消息
     */
    private String msg;

    /**
     * 返回数据
     */
    private Object data;

    /**
     * 返回状态（true代表成功，false代表失败）
     */
    private Boolean state;

    public static Result success(ResultCode resultCode ,Object data) {
        return new Result(resultCode.getCode(),resultCode.getMsg(),data,true);
    }

    public static Result success(Integer code, String msg ,Object data) {
        return new Result(code,msg,data,true);
    }

    public static Result error(ResultCode resultCode ,Object data) {
        return new Result(resultCode.getCode(),resultCode.getMsg(),data,false);
    }

    public static Result error(Integer code, String msg ,Object data) {
        return new Result(code,msg,data,false);
    }

}
